package ru.evga.inse.core.domain.dict;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

import ru.evga.inse.core.domain.BaseEntity;


@Entity
@Table(name = "city")
public class City
    extends BaseEntity
{
    @NotNull
    @Column(name="name", unique = true)
    @Size(min = 1, max = 50)
    private String name;

    public String getName()
    {
        return name;
    }

    public void setName(String name)
    {
        this.name = name;
    }

    @Override
    public boolean equals(Object obj)
    {
        if (this == obj)
        {
            return true;
        }
        if ((obj == null) || (obj.getClass() != this.getClass()))
        {
            return false;
        }
        City other = (City)obj;
        if (getName() == null)
        {
            return false;
        }
        return getName().equals(other.getName());
    }

    @Override
    public int hashCode()
    {
        int hash = 7;
        hash = accumulateHashCode(hash, getName());
        return hash;
    }

    @Override
    public String toString()
    {
        StringBuilder sb = new StringBuilder(super.toString());
        sb.append(", name:").append(getName());
        return sb.toString();
    }
}
